<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header','admin');
if($source_type==1){
    $info_type='资讯';
}elseif($source_type==2){
    $info_type='视频';
}elseif($source_type==3){
    $info_type='图集';
}
?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script>
<div class="pad-10">
<form name="searchform" action="" method="get" >
<input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
<input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
<input type="hidden" value="<?php echo ROUTE_A;?>" name="a">
	<input type="hidden" value="<?php echo isset($source_type)?$source_type:1;;?>" name="source_type">
<input type="hidden" value="<?php echo $id;?>" name="id"><!-- 视频集ID -->
	<input type="hidden" value="<?php echo $catid;?>" name="catid">
	<!-- <input type="hidden" value="<?php echo $id;?>" name="id"> -->
<input type="hidden" value="<?php echo $contest_id;?>" name="contest_id">
<input type="hidden" value="<?php echo $sid;?>" name="sid">
<input type="hidden" value="<?php echo $agency_id;?>" name="agency_id">
<input type="hidden" value="<?php echo $talent_id;?>" name="talent_id"><!-- 人才ID -->
<input type="hidden" value="<?php echo $course_id;?>" name="course_id"><!-- 课程ID -->
	<input type="hidden" value="" name="relation" id="relation">

<table width="100%" cellspacing="0" class="search-form">
    <tbody>
		<tr>
		<td align="">
		<div class="explain-col">
				<?php echo L('type')?>：
				<select name="typeid" id="typeid">
				<option value="0">请选择</option>
				<?php echo $select_categorys;?>
				</select>
				标题
				<input name="keywords" type="text" value="<?php echo stripslashes($_GET['keywords'])?>" style="width:330px;" class="input-text" />
				<input type="submit" name="search" class="button" value="<?php echo L('search');?>" />
				<a class="button" href="javascript:;" onClick="ajax_type_source();" onMouseOver="show_onekey_info();" onMouseOut="hide_onekey_info();">一键导入</a><span id="onekey_info" style="display:none;color:red;font-size:14px;"><br>说明：一键导入是当关联<?php echo $info_type;?>时，先选择<?php echo $info_type;?>类型的二级分类，再点击一键导入即可实现关联此分类下所有的<?php echo $info_type;?>资源！</span>
	</div>
		</td>
		</tr>
    </tbody>
</table>
</form>
<div class="table-list">
    <table width="100%" cellspacing="0" >
        <thead>
            <tr>
            	<th width="16"><input type="checkbox" value="" id="check_box" onclick="selectalls('id[]');"></th>
				<th align="left">ID</th>
				<th align="left"><?php echo L('title')?></th>
				<th align="left"><?php echo L('image_cover')?></th>
				<th align="left"><?php echo '上次编辑者'?></th>
            </tr>
        </thead>
    <tbody id="select_id">
	<?php if (!empty($infos)){ foreach($infos as $v) { ?>
	<tr onclick="select_list(this,<?php echo $v['id'];?>)" class="cu" title="<?php echo L('click_to_select');?>">
		<td align="center"><input class="inputcheckbox " name="id[]" value="<?php echo $v['id'];?>" type="checkbox"></td>
		<td align="left"><?php echo $v['id']?></td>
		<td align="left"><?php if(empty($v['title'])){echo"<span style='color:red;'>（未设置）</span>";}else{echo $v['title'];}?></td>
		<td align="left"><?php if(!empty($v['image_cover'])){?><img src="<?php echo $v['image_cover'];?>" height="60"/><?php }else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
		<td align="left"><?php if(empty($v['updated_by'])){echo"<span style='color:red;'>（未设置）</span>";}else{echo $adminInfo[$v['updated_by']];}?></td>
	</tr>
	 <?php } }else{
	 	echo "<tr><td colspan='5' style='color:red;font-size:18px;text-align:center;'><span>暂无数据！</span></td></tr>";
	 	}?>
	    </tbody>
    </table>
   <div id="pages"><?php echo $pages;?></div>
</div>
</div>
<style type="text/css">
 .line_ff9966,.line_ff9966:hover td{
	background-color:#FF9966;
}
 .line_fbffe4,.line_fbffe4:hover td {
	background-color:#fbffe4;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
	function selectalls(name) {
		//alert($('#select_id tr .inputcheckbox').length);
		var objs = $('#select_id tr .inputcheckbox');
		var strs = '';
		if ($("#check_box").attr("checked")=='checked') {
			$("input[name='"+name+"']").each(function() {
	  			$(this).attr("checked","checked");
	  			
				$('#select_id tr').attr('class','line_ff9966');
			});
			for(var i=0; i<objs.length; i++){
				if (i == 0) {
					if(objs[i].checked) strs = objs[i].value;
				} else {
					if(objs[i].checked) strs +='|' + objs[i].value;
				}
			}
			$('#relation').val(strs);
		} else {
			$("input[name='"+name+"']").each(function() {
	  			$(this).removeAttr("checked");
	  			$('#select_id tr').attr('class','line_fbffe4')
	  			$('#relation').val('');
			});
		}
	}

	function ajax_type_source () {
		var type_id = $('#typeid').val();

		var url = '<?php echo $url;?>';
		if (type_id > 0) {
			$.ajax({
				type:"get",
				url:url+"&type_id="+type_id+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
				dataType: "json",
				success:function(data){
					if(data['status']){
						setcookie('refersh_time', 1);
						window.top.art.dialog({
							id: 'select'
						}).close()
					}else{
						alert(data['msg']);
						return false;
					}
				}
			})
		} else {
			alert('请先选择类型！');
		}
	}

	function select_list(obj,id) {
		var relation_ids =$('#relation').val();
		if($(obj).attr('class')=='line_ff9966' || $(obj).attr('class')==null) {
			$(obj).attr('class','line_fbffe4');
			$(obj).find('.inputcheckbox').removeAttr("checked");
			if(relation_ids !='' ) {
				var r_arr = relation_ids.split('|');
				var newrelation_ids = '';
				$.each(r_arr, function(i, n){
					if(n!=id) {
						if(i==0) {
							newrelation_ids = n;
						} else {
						 newrelation_ids = newrelation_ids+'|'+n;
						}
					}
				});
				$('#relation').val(newrelation_ids);
			}
		} else {
			$(obj).attr('class','line_ff9966');
			$(obj).find('.inputcheckbox').attr("checked","checked");
			if(relation_ids =='' ) {
				$('#relation').val(id);
			} else {
				relation_ids = relation_ids+'|'+id;
				$('#relation').val(relation_ids);
			}
		}
}
	/**
    *time：2017-05-17 15:41:50
    *author：angel_in_us
    *description：鼠标移动事件，解释一键导入功能
	**/
	function show_onekey_info(){
	    $("#onekey_info").css("display","block");
	}
	function hide_onekey_info(){
	    $("#onekey_info").css("display","none");
	}
//-->
</SCRIPT>
</body>
</html>